package com.ddh.bankmanager.config;
 
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import javax.annotation.Resource;

/**
 * @author young
 * @date 2022/9/12 15:36
 * @description: JWT拦截配置
 */
@Configuration
public class InterceptorConfig implements WebMvcConfigurer {

    @Resource
    private MyJwtInterceptor jwtInterceptor;
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(jwtInterceptor)
                //拦截所有请求，通过判断token来决定是否需要登陆
                .addPathPatterns("/**")
                .excludePathPatterns("/customerInfo/login")
                .excludePathPatterns("/customerInfo/register")
                .excludePathPatterns("/doc.html")
                .excludePathPatterns("/webjars/**")
                .excludePathPatterns("/v2/api-docs/**")
                .excludePathPatterns("/swagger-resources/**");
    }
 
//    @Bean
//    public MyJwtInterceptor jwtInterceptor(){
//        return new MyJwtInterceptor();
//    }
}